package be.vdabantwerpen.gow.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import be.vdabantwerpen.gow.dao.UserDAO;
import be.vdabantwerpen.gow.dao.UserDAOImpl;
import be.vdabantwerpen.gow.entities.GOWUser;
import be.vdabantwerpen.gow.services.UserService;

/**
 * Servlet implementation class ProfielgeWijzigdServlet
 */
@WebServlet("/user/profielgewijzigd.htm")
public class ProfielgeWijzigdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final String VIEW = "/WEB-INF/JSP/user/profielgewijzigd.jsp";
	private static final UserDAO userDAO = new UserDAOImpl();

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// werk met datastore
//		String userName = request.getParameter("username");
		String userIdAlsString = request.getParameter("userid");
		int userId = Integer.parseInt(userIdAlsString);
		GOWUser user = userDAO.read(userId);
		// werk met cookie
		// HttpSession session = request.getSession();
		// if (session != null) {
		// User user = (User) session.getAttribute("user");
		request.setAttribute("user", user);
		request.getRequestDispatcher(VIEW).forward(request, response);
		// }

	}
}
